<template>
  <div class="EmployeeInformation">
    <div class="FormPanelDiv">
      <FormPanel :list="formList" labelWidth="100" :cols="3" formType="show" :isSubmitBtn="false" />
    </div>
    <!-- <div class="imgDiv" :style="{background: 'url(' + headPortrait + ') no-repeat center center'}"></div> -->
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { getUserInfoList } from '@/api/common/auth/userInfo/index.js';

export default {
  name: 'EmployeeInformation',
  mixins: [dictionary],
  data() {
    return {
      formList: this.createFormList(),
      headPortrait: ''
    };
  },
  created() {
    this.getUserInfo();
    this.getCookie();
  },
  methods: {
    getCookie() {
      let allCookie = document.cookie.split(';');
      allCookie.forEach(x => {
        if (x.indexOf('dataType') > -1) {
          this.dataType = x.split('=')[1];
        }
      });
      //判断是否为车厂10461003
      console.log(this.dataType, 'dataType');
      if (this.dataType == 10461003) {
        console.log(this.dataType, '车厂');
      }
    },
    //请求数据
    async getUserInfo() {
      await getUserInfoList()
        .then(res => {
          console.log(res, 'res');
          this.headPortrait = res.data.headPortrait;
          this.formList.forEach(x => {
            x.initialValue = res.data[x.fieldName];
          });
          // this.formList[0].initialValue=Date(res.data.createdAt)
          // this.formList[5].initialValue=Date(res.data.dimissionDate)
          // this.formList[10].initialValue=Date(res.data.birthday)
        })
        .catch();
    },
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '创建日期',
          fieldName: 'createdAt',
          placeholder: '',
          initialValue: ''

          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '员工编号',
          fieldName: 'employeeNo',
          hidden:true,
          placeholder: '',
          initialValue: ''

          // itemList: [{ text: '热点', value: '1' }, { text: '资讯', value: '2' }],
          // rules: [{ required: true, message: '请选择所属分类', trigger: 'change' }]
        },
        {
          type: 'INPUT',
          label: '登录账号',
          fieldName: 'userCode',
          placeholder: '',
          initialValue: ''

          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '所属部门',
          fieldName: 'orgName',
          placeholder: '',
          initialValue: ''

          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '在职状态',
          fieldName: 'employeeStatus',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('1008')
          // render: props => {
          //   return <span>{this.createDictText(props.row.title3, '1008')}</span>;
          // }
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        // {
        //   type: 'INPUT',
        //   label: '离职日期',
        //   fieldName: 'dimissionDate',
        //   placeholder: '',
        //   initialValue: ''

        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        {
          type: 'INPUT',
          label: '员工姓名',
          fieldName: 'employeeName',
          placeholder: '',
          initialValue: ''

          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '手机号码',
          fieldName: 'mobilePhone',
          placeholder: '',
          initialValue: ''

          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '性别',
          fieldName: 'gender',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('1002')
          // render: props => {
          //   return <span>{this.createDictText(props.row.title7, '1002')}</span>;
          // }
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        // {
        //   type: 'INPUT',
        //   label: '身份证号',
        //   fieldName: 'certificateId',
        //   placeholder: '',
        //   initialValue: ''

        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'INPUT',
        //   label: '出生日期',
        //   fieldName: 'birthday',
        //   placeholder: '',
        //   initialValue: ''

        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'INPUT',
        //   label: 'Email',
        //   fieldName: 'eMail',
        //   placeholder: '',
        //   initialValue: ''

        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'SELECT',
        //   label: '是否冻结',
        //   fieldName: 'lockFlag',
        //   placeholder: '',
        //   initialValue: '',
        //   itemList: this.createDictList('1004')
        //   // render: props => {
        //   //   return <span>{this.createDictText(props.row.title11, '1004')}</span>;
        //   // }
        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // }
      ];
    }
  }
};
</script>

<style lang="less" scoped>
.FormPanelDiv {
  margin: 20px 20px 20px 0px;
}
.imgDiv {
  width: 10%;
  min-height: 150px;
  border: 1px solid #000;
  float: left;
  background-size: cover !important;
}
</style>
